﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Linq;

namespace Admin.cadastros
{
    /// <summary>
    /// Summary description for usuario
    /// </summary>
    public class usuario : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string _usulog = context.Request["usulog"];
            if (!String.IsNullOrEmpty(_usulog))
            {
                using (LojaAdminDataContext dc = new LojaAdminDataContext())
                {
                    Table<Usuario> tblUser = dc.GetTable<Usuario>();
                    Usuario user = tblUser.Where(u => u.UsuLog == _usulog).SingleOrDefault();
                    Donini.Crypt.Crypt c = new Donini.Crypt.Crypt(Donini.Crypt.CryptProvider.Rijndael);
                    c.Key = "chocolate";
                    context.Response.Write(@"{usuLogin:'" + user.UsuLog + "', usuNome: '" + user.UsuNom + "'," + 
                                             "usuSenha:'" + c.Decrypt(user.UsuSen) +"'," + "usuSta:'" + user.UsuSta + "'," + 
                                             "usuTelefone:'" + user.UsuTel + "'," + "usuMail:'" + user.UsuMai + "'}");
                }
            }



        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}